<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>{$Think.lang.chip_transfer}</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="INDEX/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="INDEX/css/main.css"/>
		<link rel="stylesheet" type="text/css" href="INDEX/js/transfer.css"/>
	</head>
<style>
	.more_history {
		 text-align: center;
		padding: 0.5em;
	}
   .mui-switch{
      		width:36px;
        	height:18px;
      }
      header div{
      		top : 30%;
      }
      .mui-switch .mui-switch-handle{
      		width:20px;
        	height:20px;
        left:-4px;
        top: -3px;
      }
      .mui-switch.mui-active:before{
      	top:-3px;
        left:1px;
      }
      .mui-switch.mui-active .mui-switch-handle {
    	-webkit-transform: translate(43px,0);
    	transform: translate(20px,0);
		}
      .mui-switch:before{
      		top:-3px;
        	left:15px;
      }
</style>
	<body>
		<script src="INDEX/js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		<script src="INDEX/js/jquery-1.8.0.min.js" type="text/javascript" charset="utf-8"></script>
		<header class="mui-bar mui-bar-nav">
			<a href="#offCanvasSide" class="right_top"></a>
			<!--<a class="mui-switch "></a>-->
			<div class="mui-switch mui-pull-right {if $think_var=='zh-cn'}mui-active{/if}" id="mySwitch">
  				<div class="mui-switch-handle"></div>
			</div>
			<h1 class="mui-title">{$Think.lang.project_title}</h1>
		</header>
		<div id="offCanvasWrapper" class="mui-off-canvas-wrap mui-slide-in">
			<div id="header">{include file='header'/}</div>
			<div class="mui-inner-wrap">
				<div id="offCanvasContentScroll" class="mui-content mui-scroll-wrapper mui-slide-in">
					<div class="mui-scroll">
						<div class="transfer_content">
							<div class="transfer_top">
								<div class="now_money">
									<h4 style="display: inline-block;">{$Think.lang.tra_now}</h4>
									&nbsp;
									<span class="userable_money" style="color: #FD1B1B;">${$res['jetton']}</span>
									<input type="hidden" id="jetton" value="{$res['jetton']}">
								</div>
								<div class="user_accutent">
									<h4>{$Think.lang.tra_user_name}</h4>
									<input type="text" name="accutment" id="accutment" value="" placeholder="{$Think.lang.tra_user_name_input}"/>
								</div>
								<div class="user_money">
									<h4>{$Think.lang.tran}</h4>
									<input type="number" name="cash_money" id="cash_money" value="" max="{$res['jetton']}" placeholder="{$Think.lang.tran_input}"/>
								</div>
							</div>
							<div class="transfer_middle">
								<div class="done_transfer">{$Think.lang.tra_over}</div>
								<div class="cash_history">
									<div class="cash_history_title">{$Think.lang.tra_over_record}</div>
									<div class="history_table">
										<div class="table_box">
											<table border="" id="tabody" cellspacing="5" cellpadding="5" rules="none" class="return_parent">
												<tr>
													<th>{$Think.lang.user_mebmer}</th>
													<th>{$Think.lang.tra_money}</th>
													<th>{$Think.lang.tra_time}</th>
													<th>{$Think.lang.user_operation}</th>
												</tr>
											</table>
										</div>
										<div class="more_history">{$Think.lang.put_load_more}</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>	
		</div>
	</body>
	<script src="INDEX/js/switchover.js"></script>
	<script type="text/javascript">
	var more=document.getElementsByClassName("more_history")[0];
	more.addEventListener("tap", function () {
		pullfreshfunction();
	});

	var pageStart = 1;//开始数据条数
	pullfreshfunction();
	function pullfreshfunction() {
		var __self=this;
		var url = "{:Url('Order/transfer_list')}";
		var page = pageStart;
		var str="";
		mui.ajax({
			type: "post",
			url: url,
			timeout: 10000,
			data: {
				page: page
			},
			dataType: "json",
			success: function (data) {
				if (data.code == 0) {
					var list = data.data;
					for (i in list) {
                        str+= "<tr>"+
                                "<td>"+list[i].user_name+"</td>"+
                                "<td>$"+list[i].money+"</td>"+
                                "<td>"+list[i].create_time+"</td>"+
                                "<td>";
                                if(list[i].from_type == 5){
                                    str += "<span class='return' id='"+list[i].id+"'>{$Think.lang.tra_withdraw}</span>";
                                }
                        str += "</td></tr>";
					}
					document.getElementById("tabody").innerHTML+=str;
					pageStart++;
				}else{
					mui.toast(data.message);
				}
			},
			error: function (XMLHttpRequest, textStatus, errorThrown) {
				console.log("请求失败!!！" + textStatus);
			}
		});

	}
		mui('#offCanvasSideScroll').scroll();
		mui('#offCanvasContentScroll').scroll();
		// $(".return").click(function(){
			mui.ready(function(){
				// var returns=document.getElementsByClassName("return");
				// returns.addEventListener("tap", function () {
					mui(".return_parent").on("tap",".return",function(){
						var balance_id = this.getAttribute('id')
						// var money = 
					mui.prompt("","{$Think.lang.tran_input}","",['{$Think.lang.btn_sure}'],function(e,msg){
						if(e.index==0){
							var money = e.value;
							$.post("{:Url('Order/recall')}", {
								"balance_id" : balance_id,
								"money" : money,
							}, function(data) {
								if (data['code'] > 0) {
									mui.toast(data["message"])
								} else {
									mui.toast(data["message"])
								}
                              setTimeout(function(){
                            window.location.reload();
                        },1000);
							});			
						}else{
							return
						}
					})
				})
			})
			
		var done_transfer = document.getElementsByClassName("done_transfer")[0];
		done_transfer.addEventListener("tap", function () {
			var username=$("#accutment").val();
			if(username == ""){
				mui.toast("{$Think.lang.empty_username}");
				return false;
			}
			var money = $("#cash_money").val();
			if(money == "")
			{
				mui.toast("{$Think.lang.tra_empty_money}");
				return false;
			}
			var jetton = $("#jetton").val();

			mui.confirm("{$Think.lang.tra_sure}"+username,"",['{$Think.lang.btn_cancel}','{$Think.lang.btn_sure}'],function(e){
				if(e.index==1){
					$.post("{:Url('Order/transfer')}", {
                "username" : username,
                "money" : money,
				'jetton' : jetton
            }, function(data) {
                if (data['code'] > 0) {
					mui.toast(data["message"])
                } else {
                    mui.toast(data["message"])
                }
                setTimeout(function(){
                            window.location.reload();
                        },1000);	
            });
				}else{
					return
				}
			})
		})

	</script>

</html>